<template>
  <el-table
    border
    :data="shipmentList"
    show-summary
    :summary-method="getSummaries"
  >
    <el-table-column
      label="货件单号"
      prop="shipmentNo"
    ></el-table-column>
    <el-table-column
      label="货件类型"
      prop="type"
    >
      <template v-slot="{row}">
        {{getShipmentTypeStr2(row.shipmentType)}}
      </template>
    </el-table-column>
    <el-table-column
      label="贴SKU标费用（元）"
      prop="labelFee"
    ></el-table-column>
    <el-table-column
      label="直送费用（元）"
      prop="fullInWarehouseFee"
    ></el-table-column>
    <el-table-column
      label="组装费用（元）"
      prop="combinationFee"
    ></el-table-column>
    <el-table-column
      label="合计"
      prop="sumFee"
    ></el-table-column>
  </el-table>
</template>

<script>
import {getShipmentTypeStr, getShipmentTypeStr2} from "@/utils/shipment";

export default {
  name: 'PlanShipmentList1',
  props: {
    shipmentList: {
      type: Array,
      required: true,
    }
  },
  methods: {
    getShipmentTypeStr2,
    getShipmentTypeStr,
    getSummaries(param){
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = this.$t('table.sum');
          return;
        }
        if(index === 1){
          sums[index] = '-'
          return;
        }

        sums[index] = data.reduce((prev,curr)=>{
          if(curr[column.property]){
            return prev  + Number(curr[column.property])
          }else{
            return prev
          }
        },0)
      });

      return sums;
    },
  }
}
</script>

<style scoped lang="scss">

</style>
